package com.lingnan.tijian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lingnan.tijian.domain.CheckItem;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lingnan.tijian.common.annotation.Log;
import com.lingnan.tijian.common.core.controller.BaseController;
import com.lingnan.tijian.common.core.domain.AjaxResult;
import com.lingnan.tijian.common.enums.BusinessType;
import com.lingnan.tijian.domain.CheckItemDetailed;
import com.lingnan.tijian.service.ICheckItemDetailedService;
import com.lingnan.tijian.common.utils.poi.ExcelUtil;
import com.lingnan.tijian.common.core.page.TableDataInfo;

/**
 * 检查项明细Controller
 * 
 * @author laoda
 * @date 2025-01-05
 */
@RestController
@RequestMapping("/tijian/check_item_detailed")
public class CheckItemDetailedController extends BaseController
{
    @Autowired
    private ICheckItemDetailedService checkItemDetailedService;

    /**
     * 查询检查项明细列表
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckItemDetailed checkItemDetailed)
    {
        startPage();
        List<CheckItemDetailed> list = checkItemDetailedService.selectCheckItemDetailedList(checkItemDetailed);
        return getDataTable(list);
    }

    /**
     * 导出检查项明细列表
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:export')")
    @Log(title = "检查项明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckItemDetailed checkItemDetailed)
    {
        List<CheckItemDetailed> list = checkItemDetailedService.selectCheckItemDetailedList(checkItemDetailed);
        ExcelUtil<CheckItemDetailed> util = new ExcelUtil<CheckItemDetailed>(CheckItemDetailed.class);
        util.exportExcel(response, list, "检查项明细数据");
    }

    /**
     * 获取检查项明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(checkItemDetailedService.selectCheckItemDetailedById(id));
    }

    /**
     * 新增检查项明细
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:add')")
    @Log(title = "检查项明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckItemDetailed checkItemDetailed)
    {
        return toAjax(checkItemDetailedService.insertCheckItemDetailed(checkItemDetailed));
    }

    /**
     * 修改检查项明细
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:edit')")
    @Log(title = "检查项明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckItemDetailed checkItemDetailed)
    {
        return toAjax(checkItemDetailedService.updateCheckItemDetailed(checkItemDetailed));
    }

    /**
     * 删除检查项明细
     */
    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:remove')")
    @Log(title = "检查项明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(checkItemDetailedService.deleteCheckItemDetailedByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('tijian:check_item_detailed:list')")
    @GetMapping("/ListNameAndId")
    public TableDataInfo ListNameAndId()
    {
        System.out.println("111111111111111111");
        List<CheckItem> list = checkItemDetailedService.selectCheckItemDetailedIdAndName();
        System.out.println(list);
        System.out.println("2222");
        return getDataTable(list);
    }
}
